#!/bin/bash

# =================================================================================================
#
#                    Netscape - a Customized browser for HMC
#          
# This configuration file is used to copy the default X resources for HMC based Netscape Browser.
# 
# The following are the steps to configure the X resources
#
# 1. Copy the customized Netscape.ad to /usr/X11R6/lib/X11/app-defaults/Netscape/ directory
# 2. Run the xrdb with merge option (ie, xrdm -merge Netscape.ad) to set the RESOURCE_MANAGER or the 
#    SCREEN_MANAGER
# 3. Add Introduction html as a argument to netscape program in /usr/X11R6/lib/X11/icewm/toolbar file 
# 4. Set HMC index.html as a home page to /usr/bin/netscape file
#
# ===================================================================================================



#run the xrdb with merge option to set the netscape X resources
#For more info: see the man pages for xrdb

/usr/bin/X11/xrdb -merge /usr/lib/X11/app-defaults/Netscape/Netscape.ad 2>/tmp/netsacpe.config

#edit the toolbar file to start the netscape with index file
#/bin/sed -e 's/prog Netscape netscape netscape/prog Netscape netscape netscape \/opt\/hsc\/help\/$LANG\/commonhelp\/hscguide\/index.html/' /usr/lib/X11/icewm/toolbar   > /usr/lib/X11/icewm/toolbar.mod

/bin/sed -e 's/#prog Netscape netscape netscape/prog Netscape netscape hmcBrowserLaunch/' /usr/lib/X11/icewm/toolbar   > /usr/lib/X11/icewm/toolbar.mod

/bin/cp /usr/lib/X11/icewm/toolbar.mod /usr/lib/X11/icewm/toolbar
/bin/rm -rf /usr/lib/X11/icewm/toolbar.mod


# set the HMC index file to netscape wrapper
#/bin/sed -e 's/usr\/share\/doc\/HTML\/index.html/opt\/hsc\/help\/$LANG\/commonhelp\/hscguide\/index.html/' /usr/bin/netscape > /usr/bin/netscape.mod

#/bin/cp /usr/bin/netscape.mod /usr/bin/netscape
#/bin/rm -rf /usr/bin/netscape.mod

# ====================================================================================================
#              Access Control for Apache
#
#  Access control is implemented using Apache directives. 
#  Deny from all - denies the acces from all domains
#  Allow from all - allow the access from all domains
#
# For more detailed information on access control, please visit to http://httpd.apache.org/docs/
# ====================================================================================================

#check if the apache server is running, if yes, then stop the server

ps_apache=`ps -ef | grep httpd`
if [ "$ps_apache" != "" ]
then
     /etc/rc.d/init.d/httpd stop > /dev/null 2>&1
fi



hmcTagFinder=`grep -Fw "#HMC Configuration" /etc/httpd/conf/httpd.conf`

if [ "$hmcTagFinder" == "" ]
then
   echo adding HMC specific entries to httpd.conf 
   echo "

#HMC Configuration"  >> /etc/httpd/conf/httpd.conf

  /bin/sed -e 's/Options FollowSymLinks/Order allow,deny/' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.mod

  /bin/cp /etc/httpd/conf/httpd.conf.mod /etc/httpd/conf/httpd.conf
  /bin/rm -rf /etc/httpd/conf/httpd.conf.mod

  /bin/sed -e 's/AllowOverride None/Deny from all/' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.mod

  /bin/cp /etc/httpd/conf/httpd.conf.mod /etc/httpd/conf/httpd.conf
  /bin/rm -rf /etc/httpd/conf/httpd.conf.mod

  /bin/sed -e 's/Options Indexes FollowSymLinks/#Options Indexes FollowSymLinks/' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.mod

  /bin/cp /etc/httpd/conf/httpd.conf.mod /etc/httpd/conf/httpd.conf
  /bin/rm -rf /etc/httpd/conf/httpd.conf.mod

  /bin/sed -e 's/AllowOverride/#AllowOverride/' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.mod

  /bin/cp /etc/httpd/conf/httpd.conf.mod /etc/httpd/conf/httpd.conf
  /bin/rm -rf /etc/httpd/conf/httpd.conf.mod

  /bin/sed -e 's/Allow from all/Deny from all/' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.mod

  /bin/cp /etc/httpd/conf/httpd.conf.mod /etc/httpd/conf/httpd.conf
  /bin/rm -rf /etc/httpd/conf/httpd.conf.mod

  echo "

<Directory /home/*/public_html>
     AllowOverride FileInfo AuthConfig Limit
     Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
     <Limit GET POST OPTIONS PROPFIND>
         Order allow,deny
         Allow from all
     </Limit>
     <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
         Order deny,allow
         Deny from all
     </Limit>
</Directory>" >> /etc/httpd/conf/httpd.conf





echo '


<IfModule mod_alias.c>

   Alias /errordocs/ "/var/www/html/errordocs/"

   <Directory "/var/www/html/errordocs">
       AllowOverride None
       Options Multiviews FollowSymLinks
       Order allow,deny
       Allow from all 
   </Directory>

   ErrorDocument 400 /errordocs/bad_request.html
   ErrorDocument 403 /errordocs/forbidden.html
   ErrorDocument 404 /errordocs/missing.html
   ErrorDocument 500 /errordocs/server_error.html
   ErrorDocument 501 /errordocs/not_implemented.html
   ErrorDocument 503 /errordocs/service_unavailable.html

   Alias /pc_client /usr/websm/pc_client

   <Directory /usr/websm/pc_client>
       AllowOverride None
       Options All MultiViews
       Order Deny,Allow
       Allow from all
   </Directory> 

   <Directory /var/www/html/help>
       AllowOverride None
       Options All MultiViews
       Order Deny,Allow
       Allow from all
   </Directory> 

</IfModule>' >> /etc/httpd/conf/httpd.conf

fi

pcclientTagFinder=`grep -Fw "#PC-Client Configuration" /etc/httpd/conf/httpd.conf`

if [ "$pcclientTagFinder" == "" ]
then

echo adding PC client specific entries to httpd.conf
echo "

#PC-Client Configuration

<Files ~ "remote_client.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "pcctoc.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "pccwarning.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "wsmbanner.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "remote_client_security.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "pc_client.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "pc_client_security.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "pccsecwarning.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "wsmsec_not_installed.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "wsmsec_installed.html">
    Order allow,deny
    Allow from all
    Satisfy All
</Files>

<Files ~ "^\.htaccess">
    Order allow,deny
    Deny from all
    Satisfy All
</Files>" >> /etc/httpd/conf/httpd.conf

fi

#start the apache server
/etc/rc.d/init.d/httpd start > /dev/null 2>&1

 

